package pers.zb.cloud.service.upms;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.AdviceMode;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.context.request.RequestContextListener;
import tk.mybatis.spring.annotation.MapperScan;

/**
 * 【@EnableTransactionManagement注解的说明】：
 *      1、该@EnableTransactionManagement注解的作用和<tx:annotation-driven/>作用一样。
 *      2、由于项目中使用了多个DataSource数据源（对应数量的事务管理器），所以mode属性需要设置为AdviceMode.ASPECTJ，
 *         不然在调用具有@Transactional注解修饰的业务方法的时候，会报错：No qualifying bean of type 'org.springframework.transaction.PlatformTransactionManager'
 *
 *  更多关于@EnableTransactionManagement注解的描述，可参考 https://my.oschina.net/u/3775437/blog/1841903
 */
@EnableTransactionManagement(mode = AdviceMode.ASPECTJ)
@MapperScan(basePackages = "pers.zb.cloud.service.upms.dao") //mybatis mapper配置
@SpringBootApplication
public class UpmsServiceApplication {
    public static void main(String[] args) {
        SpringApplication.run(UpmsServiceApplication.class, args);
    }

    @Bean
    public RequestContextListener requestContextListener() {
        return new RequestContextListener();
    }
}
